package com.zllkj.mm.widgets;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.TextView;

public class DragView extends TextView {
  float moveX; 
  float moveY; 
  public DragView(Context context) {
    super(context); 
  } 
  public DragView(Context context, AttributeSet attrs) {
    super(context, attrs); 
  } 
  @Override 
  public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) { 
      case MotionEvent.ACTION_DOWN: 
        moveX = event.getX(); 
        moveY = event.getY(); 
        break; 
      case MotionEvent.ACTION_MOVE: 
        setTranslationX(getX() + (event.getX() - moveX)); 
        setTranslationY(getY() + (event.getY() - moveY)); 
        break; 
      case MotionEvent.ACTION_UP: 
        break; 
      case MotionEvent.ACTION_CANCEL: 
        break; 
    } 
    return true; 
  } 
} 